<form lay-filter="submit" class="layui-form submit-comb">


    <div class="layui-form-item">
        <label class="layui-form-label">选择语言</label>
        <div class="layui-input-block">
            <select name="language" >
                {foreach $lang as $k=>$v}
                {if condition="$lang_mask&(1<<$k)"}
                {if condition="isset($lang_selected)&&$lang_selected==$k"}
                <option value="{$k}" selected="">{$v}</option>
                {else/}
                <option value="{$k}" >{$v}</option>
                {/if}
                {/if}
                {/foreach}


            </select>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">代码框</label>
        <div class="layui-input-block">
            <textarea name="code" placeholder="请输入内容" class="layui-textarea" style="height: 300px;"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit" id="nyoj-submitbox-code">立即提交</button>
        </div>
    </div>

</form>
<script src="__STATIC__/jquery/base64-jquery.min.js"></script>
<script>
    layui.use(['form', 'jquery', 'layer'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        var encode_mark={$OJ_ENCODE_SUBMIT};
        form.on('submit(submit)', function (data) {
            //console.log(data.field);
            if(encode_mark=='1'){
                var tmp=new  Base64();
                data.field.code = tmp.encode(data.field.code);
            }
            //console.log(data.field);
            var disa=$("#nyoj-submitbox-code").attr("disabled"); 
            if(disa==='disabled'){
                return ;
            }
            $("#nyoj-submitbox-code").attr("disabled","disabled"); 
            $.post({
                url: '{:url('web/Problem/do_submit',['pid'=>$pid,'cid'=>$cid])}',
                dataType: 'json',
                data: data.field,
                success: function (res) {
                    if (res.code === 0) {
                        location.href=res.url;
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
        form.render("select");
    });
</script>
